import 'dart:convert';

import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'custom_model.dart';
import 'flutter_presentation_platform_interface.dart';

/// An implementation of [FlutterPresentationPlatform] that uses method channels.
class MethodChannelFlutterPresentation extends FlutterPresentationPlatform {
  /// The method channel used to interact with the native platform.
  @visibleForTesting
  final methodChannel = const MethodChannel('flutter_presentation');

  @override
  Future<String?> getPlatformVersion() async {
    final version =
        await methodChannel.invokeMethod<String>('getPlatformVersion');
    return version;
  }

  @override
  Future<void> startSubScreen(CustomModel model) async {
    return await methodChannel
        .invokeMethod<void>('startSubScreen', jsonEncode(model).toString());
  }

  @override
  Future<void> loadData(CustomModel model) async {
    return await methodChannel.invokeMethod("loadData", jsonEncode(model).toString());
  }
}
